Skip to content

Send exercise_completed to PostHog - #13173

Merged
iHiD merged 2 commits into
mainfrom
exercise-completed-analytics
Nov 26, 2026
Merged

iHiD merged 2 commits into
mainfrom
exercise-completed-analytics

Conversation

@iHiD

@iHiD iHiD commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

This PR sends an exercise_completed event to PostHog when a user completes a solution. PostHog currently only learns that someone has activated (completed an exercise other than Hello World) when site_visited refreshes their completed_non_hello_world person property on their next daily visit. With this event, PostHog will see the moment someone activates, so the retention chart can group people by the week they activated.

The event

Event Sent from When
exercise_completed server when a solution is marked as completed for the first time

It carries:

  • track and exercise (slugs).
  • A snapshot of the user's activity, as on checkout_succeeded: exercises_completed (which includes this exercise), completed_hello_world, completed_non_hello_world, mentoring_sessions and days_since_signup.
  • The standard membership_type, locale, IP and user agent.

It also refreshes the user's person properties in $set, as site_visited does, so completed_non_hello_world becomes true as soon as someone activates.

How it works

  • Solution::Complete sends the event through Analytics::TrackEvent.defer, with set_person_properties and snapshot_activity. The job works out the activity with Analytics::DetermineActivityProperties on the analytics queue, so the event adds no queries to the request.
  • Solution::Complete returns early when the solution is already completed, so the event is only sent once per solution. Publishing an already completed solution or submitting a new iteration doesn't send it again.
  • If someone deletes every iteration of a solution, Solution::Uncomplete clears its completion. If they then complete it again, the event will be sent a second time.

🤖 Generated with Claude Code

iHiD and others added 2 commits November 26, 2026 20:16
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The exercise slug already shows whether it was hello-world.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iHiD
iHiD merged commit be4d27c into main Nov 26, 2026
31 checks passed
@iHiD
iHiD deleted the exercise-completed-analytics branch November 26, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant